package com.toune.villager.model

import androidx.lifecycle.MutableLiveData
import com.toune.dltools.http.DLHttp
import com.toune.dltools.http.IDLHttpCallBack
import com.toune.dltools.ui.DLBaseViewModel
import com.toune.villager.Api
import com.toune.villager.bean.GoodsListBean

class GoodsListModel : DLBaseViewModel() {

    val goodsList = MutableLiveData<MutableList<GoodsListBean.RowsBean>>()
    fun getGoodsList(subGoodsTypeId: Int, page: Int) {
        DLHttp.get(Api.GetGoodsListUrl)
            .add("pageNum", page)
            .add("goodsTypeId", subGoodsTypeId)
            .buildByJson(object : IDLHttpCallBack<GoodsListBean>() {
                override fun success(t: GoodsListBean) {
                    goodsList.postValue(t.rows)
                }

            })
    }
}